<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <script>
      function Person(name, age) {
        this.name = name;
        this.age = age;

        // this.fight = function () {
        //   console.log(`${this.age}岁${this.name}又在干架了！`);
        // };
      }

      // 让爹（构造函数）的老婆（原型对象）学会干仗
      // 妈（类的原型对象）会把自己的全部都共享给孩子（类的实例）
      Person.prototype.fight = function () {
        console.log(`${this.age}岁${this.name}又在干架了！`);
      };

      const mjst = new Person("灭绝师太", 60);
      mjst.fight();

      const tstl = new Person("天山童姥", 80);
      tstl.fight();
    </script>
  </body>
</html>
